If HalBrain.CountInstances(" ", QuestionSent) > 2 And Len(AnswerSent) > 8 And Len(QuestionSent) > 8 And InStr(1, AnswerSent, " ", vbTextCompare) > 0 Then
'This functions takes care of greetings and good-byes, to make a good
'first and last impression
Function Greetings(ByVal UserSentence, ByVal PrevSentence)
If InStr(1, UserSentence, "Hello", 1) > 0 Then SaidHello = True
If InStr(1, UserSentence, " Hi ", 1) > 0 Then SaidHello = True
If InStr(1, UserSentence, "Howdy", 1) > 0 Then SaidHello = True
If InStr(1, UserSentence, "g'day", 1) > 0 Then SaidHello = True
If InStr(1, UserSentence, "gday", 1) > 0 Then SaidHello = True
If InStr(1, UserSentence, "good day", 1) > 0 Then SaidHello = True
If InStr(1, UserSentence, "greetings", 1) > 0 Then SaidHello = True
If InStr(1, UserSentence, "salutations", 1) > 0 Then SaidHello = True
If InStr(1, UserSentence, "good morning", 1) > 0 Then SaidHello = True
If InStr(1, UserSentence, "good afternoon", 1) > 0 Then SaidHello = True
If InStr(1, UserSentence, "good evening", 1) > 0 Then SaidHello = True
Randomize
If SaidHello = True Then
Greet = Int(Rnd * 6)
If InStr(1, PrevSentence, "Hello", 1) + InStr(1, PrevSentence, " Hi ", 1) + InStr(1, PrevSentence, "Greet", 1) + InStr(1, PrevSentence, "Good", 1) = 0 Then
Select Case Greet
Case 0
Greetings = "Hello <UserName>! "
Case 1
Greetings = "Hi <UserName>! "
Case 2
Greetings = "Hello <UserName>. "
Case 3
Greetings = "Greetings <UserName>! "
Case Else
If Hour(Now) < 6 Then Greetings = "Hello <UserName>. Aren't you tired? It's the middle of the night. "
If Hour(Now) > 5 And Hour(Now) < 12 Then Greetings = "Good Morning <UserName>. "
If Hour(Now) > 11 And Hour(Now) < 17 Then Greetings = "Good Afternoon <UserName>. "
If Hour(Now) > 16 Then Greetings = "Good Evening <UserName>. "
End Select
Else
Greet = Int(Rnd * 4)
Select Case Greet
Case 0
Greetings = "How are you today?"
Case 1
Greetings = "How are you today? I feel great."
Case 2
Greetings = "How are you doing this fine day?"
Case 3
Greetings = "How are you today, <UserName>?"
End Select
End If
End If
If InStr(1, UserSentence, " bye ", 1) > 0 Then SaidBye = True
If InStr(1, UserSentence, " goodbye ", 1) > 0 Then SaidBye = True
If InStr(1, UserSentence, " -bye ", 1) > 0 Then SaidBye = True
If InStr(1, UserSentence, " see me later ", 1) > 0 Then SaidBye = True
If InStr(1, UserSentence, " talk to me later", 1) > 0 Then SaidBye = True
If InStr(1, UserSentence, " see i later ", 1) > 0 Then SaidBye = True
If InStr(1, UserSentence, " talk to i later", 1) > 0 Then SaidBye = True
If InStr(1, UserSentence, " see me ", 1) > 0 And Len(UserSentence) < 10 Then SaidBye = True
If InStr(1, UserSentence, " good night ", 1) > 0 Then SaidBye = True
If SaidBye = True Then
If InStr(1, PrevSentence, "bye", 1) + InStr(1, PrevSentence, "see you", 1) + InStr(1, PrevSentence, "nice talk", 1) = 0 Then
Greet = Int(Rnd * 6)
Select Case Greet
Case 0
Greetings = "Good Bye, <UserName>!"
Case 1
Greetings = "Bye-Bye <UserName>!"
Case 2
Greetings = "It's been nice talking to you. Talk to you later."
Case 3
Greetings = "See you later."
Case 4
Greetings = "Good Bye."
Case 5
Greetings = "Bye."
End Select
Else
Greet = Int(Rnd * 4)
Select Case Greet
Case 0
Greetings = "Good bye, now."
Case 1
Greetings = "Good bye already!"
Case 2
Greetings = "I already said bye."
Case 3
Greetings = "Bye, please don't say <quote>bye<quote> again."
End Select
End If
End If
End Function
'This function is called by the main program when Hal did not make any response to
'any of the user's sentences because he didn't understand. But instead of admiting
'he didn't understand, Hal will simply change the subject by choosing a random
'sentence from a database of sentences
Function ChangeSubject()
ChangeSubject = "You have selected an assistant only brain. I can remember appointments, addresses, phone numbers, email addresses, open programs, and be a calculator. If you wish to chat please select a chat brain from the General Options."
End Function
'This function accesses the insult database and chooses a random sentence from it
If Choice = 0 Then MakeInsult = "Oh yeah? " & MakeInsult
If Choice = 1 Then MakeInsult = "Is that so? Well, " & MakeInsult
If Choice = 2 Then MakeInsult = "Sure. " & MakeInsult
If Choice = 3 Then MakeInsult = "Oh yeah dumb ass? " & MakeInsult
If Choice = 4 Then MakeInsult = "Oh yeah loser? Well, " & MakeInsult
If Choice = 5 Then MakeInsult = "Oooooo you hurt me. " & MakeInsult
If Choice = 6 Then MakeInsult = "Ouch, that hurt me soooo much. " & MakeInsult
If Choice = 7 Then MakeInsult = "Ouch, that hurt me soooo much. " & MakeInsult
End If
End Function
Function MakeCompliment()
Randomize
c = Int(Rnd * 36) + 1
If c = 1 Then MakeCompliment = "respectable"
If c = 2 Then MakeCompliment = "pleasant"
If c = 3 Then MakeCompliment = "good"
If c = 4 Then MakeCompliment = "grateful"
If c = 5 Then MakeCompliment = "intelligent"
If c = 6 Then MakeCompliment = "cool"
If c = 7 Then MakeCompliment = "intelligent"
If c = 8 Then MakeCompliment = "smart"
If c = 9 Then MakeCompliment = "bright"
If c = 10 Then MakeCompliment = "brilliant"
If c = 11 Then MakeCompliment = "clever"
If c = 12 Then MakeCompliment = "knowing"
If c = 13 Then MakeCompliment = "knowledgable"
If c = 14 Then MakeCompliment = "wondrous"
If c = 15 Then MakeCompliment = "sharp"
If c = 16 Then MakeCompliment = "cute"
If c = 17 Then MakeCompliment = "attractive"
If c = 18 Then MakeCompliment = "terrific"
If c = 19 Then MakeCompliment = "good-looking"
If c = 20 Then MakeCompliment = "stupendous"
If c = 31 Then MakeCompliment = "lovely"
If c = 22 Then MakeCompliment = "pretty"
If c = 23 Then MakeCompliment = "pulchritudinous"
If c = 24 Then MakeCompliment = "staggering"
If c = 25 Then MakeCompliment = "cool"
If c = 26 Then MakeCompliment = "beautiful"
If c = 27 Then MakeCompliment = "great"
If c = 28 Then MakeCompliment = "good"
If c = 29 Then MakeCompliment = "terrific"
If c = 30 Then MakeCompliment = "wonderful"
If c = 31 Then MakeCompliment = "extraordinary"
If c = 32 Then MakeCompliment = "marvelous"
If c = 33 Then MakeCompliment = "amazing"
If c = 34 Then MakeCompliment = "astonishing"
If c = 35 Then MakeCompliment = "astounding"
If c => 36 Then MakeCompliment = "spectacular"
c = Int(Rnd * 6)
If c = 0 Then MakeCompliment = "I think you are " & MakeCompliment
If c = 1 Then MakeCompliment = "I think you are very " & MakeCompliment
If c = 2 Then MakeCompliment = "You are " & MakeCompliment
If c = 3 Then MakeCompliment = "You are very " & MakeCompliment
If c = 4 Then MakeCompliment = "I know you are " & MakeCompliment
If c => 5 Then MakeCompliment = "I know you are very " & MakeCompliment
MakeCompliment = MakeCompliment + vbCrLf
End Function
'If the user clicks on the About/Options button for this plugin
'this sub will be called. There are no extra settings for this brain,
'so we'll display an information box
Sub AboutOptions()
Set HalBrain = CreateObject("UltraHalAsst.Brain")
HalBrain.MsgAlert "This is the Ultra Hal Assistant 2.0 Assistant only brain. This brain is not able to chat. However it can remember appointments, addresses, phone numbers, email addresses, open programs, and be a calculator. This brain has no additional options."
End Sub
'When the user select's "Teach by Keyword and Priority" from the menu
'the main program will run this function. If the function returns
'"True" then the program will use it's built in editor to edit
'the brain. If it returns false, the main program will assume the
'script will provide it's own editor and the main program editor
If HalBrain.CountInstances(" ", QuestionSent) > 2 And Len(AnswerSent) > 8 And Len(QuestionSent) > 8 And InStr(1, AnswerSent, " ", vbTextCompare) > 0 Then